package com.csap.framework.oauth2.client.user.strategy;

import cn.dev33.satoken.LoginUtil;
import com.csap.framework.oauth2.UserInfo;
import com.csap.framework.oauth2.UserInfoEndpoint;
import com.csap.framework.oauth2.UserInfoMod;
import com.csap.framework.oauth2.FindUserService;

/**
 * 本地查询
 *
 * @author yangchengfu
 * @dataTime 2021年-05月-16日 16:04:00
 **/
public class LocalFindUserServiceImpl implements FindUserService {
    private final UserInfoEndpoint userInfoEndpoint;

    public LocalFindUserServiceImpl(UserInfoEndpoint userInfoEndpoint) {
        this.userInfoEndpoint = userInfoEndpoint;
    }

    @Override
    public UserInfoMod mod() {
        return UserInfoMod.LOCAL;
    }

    @Override
    public UserInfo findByUserId(Object loginId) {
        return userInfoEndpoint.userInfo(loginId);
    }

    @Override
    public UserInfo findByUserId() {
        return userInfoEndpoint.userInfo(LoginUtil.getInstance().getLoginId());
    }

    @Override
    public UserInfo findByUserId(Object loginId, String loginType) {
        return userInfoEndpoint.userInfo(loginId);
    }

}
